/*******************************************************************************
 * Copyright (c) 2014 Greg Marut.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *    Greg Marut - initial API and implementation
 ******************************************************************************/
package com.gregmarut.util.encryption;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author Greg Marut
 */
public class MD5
{
	/**
	 * @param byteData
	 * @return
	 */
	public static byte[] encrypt(byte[] byteData)
	{
		// create the message digest object
		MessageDigest mdMD5;
		
		// holds the byte array to return
		byte[] byteReturn = null;
		
		try
		{
			// get an instance of the MD5 algorithm
			mdMD5 = MessageDigest.getInstance("MD5");
			
			// reset the digest
			mdMD5.reset();
			
			// assign the byte array to return
			byteReturn = mdMD5.digest(byteData);
		}
		catch (NoSuchAlgorithmException NSAE)
		{
			NSAE.printStackTrace();
		}
		
		// return the byte array
		return byteReturn;
	}
}
